package twoD.Csg;

import inf.jlinalg.IMatrix;

public class Rotation extends Transformation {

	/**
	 * 2d rotation around Oz in Oxy plane
	 * 
	 * @param ox
	 * @param oy
	 * @param alpha
	 */
	public Rotation(double ox, double oy, double alpha) {
		setD(2);
		IMatrix H = getH();
		double c = Math.cos(alpha);
		double s = Math.sin(alpha);
		H.set(0, 0, c);
		H.set(0, 1, -s);
		H.set(0, 2, c * ox - s * oy - ox);
		H.set(1, 0, s);
		H.set(1, 1, c);
		H.set(1, 2, s * ox + c * oy - oy);
	}

	/**
	 * rotation around a principal axes in 3d space
	 * 
	 * @param axes
	 * @param alpha
	 */
	public Rotation(String axes, double alpha) {
		setD(3);
		IMatrix H = getH();
		double c = Math.cos(alpha);
		double s = Math.sin(alpha);
		if (axes == "x" || axes == "X") {
			H.set(1, 1, c);
			H.set(1, 2, -s);
			H.set(2, 1, s);
			H.set(2, 2, c);
		} else if (axes == "y" || axes == "Y") {
			H.set(0, 0, c);
			H.set(0, 2, s);
			H.set(2, 0, -s);
			H.set(2, 2, c);
		} else if (axes == "z" || axes == "Z") {
			H.set(0, 0, c);
			H.set(0, 1, -s);
			H.set(1, 0, s);
			H.set(1, 1, c);
		}
	}

	/**
	 * Rotation angle alpha about the line through (a,b,c) with direction
	 * (u,v,w)
	 * 
	 * @param a
	 * @param b
	 * @param c
	 * @param u
	 * @param v
	 * @param w
	 * @param alpha
	 */
	public Rotation(double a, double b, double c, double u, double v, double w,
			double alpha) {
		setD(3);
		IMatrix H = getH();
		double cos = Math.cos(alpha);
		double sin = Math.sin(alpha);
		// TODO
	}
}
